package com.aruba.attendance.database

import androidx.annotation.NonNull
import androidx.room.Database
import androidx.room.RoomDatabase
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
import com.aruba.attendance.database.dao.OverworkDurationDao
import com.aruba.attendance.database.dao.RecordDao
import com.aruba.attendance.database.entity.OverworkDurationEntity
import com.aruba.attendance.database.entity.RecordEntity


/**
 * Created by aruba on 2023/2/15.
 */
@Database(
    entities = [RecordEntity::class, OverworkDurationEntity::class],
    version = 2,
    exportSchema = false
)
abstract class AppDatabase : RoomDatabase() {
    abstract fun recordDao(): RecordDao
    abstract fun overworkDurationDao(): OverworkDurationDao

    companion object {
        val MIGRATION_1_2: Migration = object : Migration(1, 2) {
            override fun migrate(@NonNull database: SupportSQLiteDatabase) {
                database.execSQL("ALTER TABLE RecordEntity ADD COLUMN delayDuration INTEGER ")
            }
        }
    }
}